/*        

该任务用于接收来自各个不同的控制方式所期望的控制指令 将其集中统一化后分发给各个模块

*/			
					
		





#ifndef _CMD_H
#define _CMD_H
#include "struct_typedef.h"
#include "device.h"

#define NAVI (0x05)
#define PICK (0x06)
#define PUT  (0x07)

typedef enum{
	 OPS,
	 RC,
	 CAMERA_PICK,//取球
	 CAMERA_PUT,//放球
	 SLAM_NAVI,
 }CMD_Chassis_CtrlType_e;

typedef  enum{
	 RELAXED,//异常模式
	 IMU,
	 ROTOR,//小陀螺模式
	 FOLLOW,//底盘随动
	 FIXED,
  }CMD_Chassis_mode_e;
/*该结构体负责接收和解析地盘模块所需要的控制指令*/
typedef struct{

 CMD_Chassis_CtrlType_e type;

 CMD_Chassis_mode_e mode;


}CMD_Chassis_Ctrl_t;







typedef struct {
  int16_t ch_x; 
  int16_t ch_y; 
  int16_t mul; 
  int16_t ch_w; 

  int16_t key[8];

} __attribute__((packed))CMD_RC_t;

typedef	struct
	{
		fp32 Vx;
		fp32 Vy;
		fp32 Vw;
	}OpsHopeVector_t;
typedef struct {
	
  OpsHopeVector_t out;
	
} CMD_ACTION_t;


typedef struct {
 uint8_t  status_fromnuc;
  struct 
  {
  float vx;
  float vy;
  float wz;
  }navi;

 struct 
 {
   float posy;
   float angle;
   char  cmd;
 }pick;

 struct 
  {
   uint8_t pos; //第几个框
   float angle; //角度
  }put; 
 
} CMD_NUC_t;

typedef struct{
	 float posy;
   float angle;
   char  cmd;	
}CMD_FOR_PICK;

typedef struct{
   uint8_t pos; //第几个框
   float angle; //角度
}CMD_FOR_PUT;



typedef  struct {
  float vx;
  float vy;
  float wz;
}CMD_FOR_NAVI;
typedef struct {
   uint8_t cmd_status;//由nuc判断并决定

   int32_t Vx;
   int32_t Vy;
   int32_t Vw;
	  
  
	CMD_Chassis_Ctrl_t C_cmd;
	CMD_FOR_NAVI C_navi;
	CMD_FOR_PUT C_put;
	CMD_FOR_PICK C_pick;
	
} CMD_t;


int8_t CMD_Init(CMD_t *cmd);

int8_t CMD_ParseRc(CMD_t *cmd,CMD_RC_t *rc);

int8_t CMD_ParseAct(CMD_t *cmd,CMD_ACTION_t *act);

int8_t CMD_ParseNuc(CMD_t *cmd,CMD_NUC_t *n);

void R12ds_ErrorDect(CMD_t *cmd,CMD_RC_t *rc);

int8_t CMD_SwitchStatus(CMD_t *cmd);

#endif 

